﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace JqueryNet.FormControl.FormHtmlControl
{
    public class JHtmlInputRadioButton : JHtmlControl
    {
        private System.Web.UI.HtmlControls.HtmlInputRadioButton htmlInputRadioButton;

        public JHtmlInputRadioButton(System.Web.UI.HtmlControls.HtmlInputRadioButton htmlInputRadioButton):base(htmlInputRadioButton)
        {
            // TODO: Complete member initialization
            this.htmlInputRadioButton = htmlInputRadioButton;            
        }


        public override void Attr(string key)
        {
            if (key.ToLower() == "checked")
            {
                Value = htmlInputRadioButton.Checked;
            }
            else
            {
                base.Attr(key);
            }
        }

        public override void Attr(string key, string value)
        {
            bool f;
            bool.TryParse(value, out f);
            if (key.ToLower() == "checked")
            {
                htmlInputRadioButton.Checked = f;
            }
            else
            {
                base.Attr(key, value);
            }
        }

        public override void Val()
        {
            Value = htmlInputRadioButton.Value;
        }

        public override void Val(string value)
        {
            htmlInputRadioButton.Value = value;
        }
    }
}
